package com.sport.model.excel;


import com.baomidou.mybatisplus.annotation.TableField;
import com.sport.model.excel.annotation.ExcelField;
import com.sport.model.excel.annotation.ExcelFields;
import lombok.Data;

import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;

@Data
public class SportMemberEnrollExcelTemplate {
    /**
     * 比赛成员名称
     */
    @TableField("sport_member_name")
    private String sportMemberName;

    @TableField("sport_member_gender")
    private String sportMemberGender;

    /**
     * json字符串，比赛成员报名项目，记录单项比赛项目的id
     */
    @TableField("sport_member_project1")
    private String sportMemberProject1;

    /**
     * json字符串，比赛成员报名项目，记录单项比赛项目的id
     */
    @TableField("sport_member_project2")
    private String sportMemberProject2;

    @TableField("sport_member_project3")
    private String sportMemberProject3;


    @TableField("sport_member_project4")
    private String sportMemberProject4;
    @TableField("sport_member_project5")
    private String sportMemberProject5;

    public Map<String,Object> getProperAsMap(){
        Map<String, Object> propertyMap = new HashMap<>();
        try {
        Field[] fields = this.getClass().getDeclaredFields();
        for (Field field : fields) {
            if (field.getName().equals("sportMemberName") || field.getName().equals("sportMemberGender")) {
                continue;
            }
            field.setAccessible(true);
            String fieldName = field.getName();
            Object fieldValue = field.get(this);
            propertyMap.put(fieldName,fieldValue);
        }
            } catch (IllegalAccessException e) {
                throw new RuntimeException(e);
            }

        return propertyMap;

    }
    @ExcelFields({
            @ExcelField(title = "姓名",attrName = "sportMemberName",align= ExcelField.Align.CENTER,sort = 20),
            @ExcelField(title = "性别",attrName = "sportMemberGender",align= ExcelField.Align.CENTER,sort = 20),
            @ExcelField(title = "比赛项目1",attrName = "sportMemberProject1",align= ExcelField.Align.CENTER,sort = 20),
            @ExcelField(title = "比赛项目2",attrName = "sportMemberProject2",align= ExcelField.Align.CENTER,sort = 20),
            @ExcelField(title = "比赛项目3",attrName = "sportMemberProject3",align= ExcelField.Align.CENTER,sort = 20),
            @ExcelField(title = "比赛项目4",attrName = "sportMemberProject4",align= ExcelField.Align.CENTER,sort = 20),
            @ExcelField(title = "比赛项目5",attrName = "sportMemberProject5",align= ExcelField.Align.CENTER,sort = 20),
    })

    public SportMemberEnrollExcelTemplate() {
    }
}
